package feri.lenobe;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.google.api.translate.Language;
import com.google.api.translate.Translate;
import android.widget.Spinner;

public class PrevodBesedila extends Activity{
	
	//Komponente GUI
	private Button btnPrevedi;
	private EditText editTextP;
	
	//Funkcije
	
	private enum JezikPrevoda
	{
		AUTO, Slovenscina, Anglescina;
	}
	 
	@SuppressWarnings("deprecation")
	public String Prevedi(JezikPrevoda izJezika, JezikPrevoda vJezik, String besedilo)
	{
		Translate.setHttpReferrer("https://sites.google.com/site/pessimistdrew");
		String prevedeno="";
		try {
			prevedeno = Translate.translate(besedilo, Language.ENGLISH, Language.SLOVENIAN);
		} catch (Exception e) {
			e.printStackTrace();
			return e.getMessage();
		}		
		return prevedeno;
	}
	
	//Metode GUI
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.prevodbesedila);
        
        editTextP = (EditText)this.findViewById(R.id.editBesediloZaPrevod);
        btnPrevedi = (Button)this.findViewById(R.id.gumbPrevedi);
        btnPrevedi.setOnClickListener(new OnClickListener() {
		public void onClick(View arg0) {
			Editable temp = editTextP.getText();
			String temp2 = temp.toString();
			temp2 = Prevedi(null, null, temp2);
			editTextP.setText(temp2);
		}
        });
    }
}
